package com.bike.bikeserver.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bike.bikeserver.common.core.domain.CommonResult;
import com.bike.bikeserver.common.utils.StringUtils;
import com.bike.bikeserver.domain.ModelTestLog;
import com.bike.bikeserver.mapper.ModelTestLogMapper;
import com.bike.bikeserver.service.IModelTestLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author ZZX
 * @since 2023-08-07
 */
@Service
public class ModelTestLogServiceImpl extends ServiceImpl<ModelTestLogMapper, ModelTestLog> implements IModelTestLogService
{

    @Autowired
    ModelTestLogMapper modelTestLogMapper;

    @Override
    public CommonResult getLogList()
    {
        List<ModelTestLog> modelTestLogs = modelTestLogMapper.selectList(null);
        return CommonResult.success(modelTestLogs);
    }

    @Override
    public CommonResult getLogListLikePerson(String tester)
    {
        if (tester == null || StringUtils.isBlank(tester))
        {
            return CommonResult.warn("请勿提交空值！");
        }
        LambdaQueryWrapper<ModelTestLog> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(ModelTestLog::getModelTester, tester);
        List<ModelTestLog> modelTestLogs = modelTestLogMapper.selectList(wrapper);
        return CommonResult.success("查询成功！为您找到" + modelTestLogs.size() + "条记录！", modelTestLogs);
    }
}
